// 基于axios的请求模块
import axios from 'axios'
import { login } from 'kwapi/dist/common/utils'
// 请求发给axios进行配置
const request = axios.create({
  baseURL: 'https://activityc.cekid.com',
  withCredentials: true, // 允许携带cookie
  timeout: 50000, // 请求的超时时间
  // headers: {
  //   'Content-Type': 'application/json;charset=UTF-8'
  // }
  headers: {
    'Content-Type': 'text/plain;charset=UTF-8'
  }
})
request.interceptors.response.use(response => {
  console.log(response);
  if (response.data.code === 1005) {
    login()
  }
  return response
}, err => {
  console.log(err);
})

export default request
